package com.mrcoder.sbmexcel.model;

import cn.hutool.core.util.RandomUtil;
import com.mrcoder.sbmexcel.utils.excel.BigDecimalUtils;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.*;

public class Boad2 extends Boad1 {

    private String name;
    private BigDecimal payoutCapital = BigDecimalUtils.SYSTEM_ZERO;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public BigDecimal getPayoutCapital() {
        return payoutCapital;
    }

    public void setPayoutCapital(BigDecimal payoutCapital) {
        this.payoutCapital = payoutCapital;
    }

    @Override
    public String autoShowCard() {
        return "autoShowCard 2";
    }

    public static void main(String[] args) {

//        Random rand = new Random(47);
//        Integer[] ia = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
//        List<Integer> list = new ArrayList<Integer>(Arrays.asList(ia));
//        System.out.println("Before shufflig: " + list);
//        Collections.shuffle(list, rand);
//        System.out.println("After shuffling: " + list);
//        System.out.println("array: " + Arrays.toString(ia));
//        List<Integer> list1 = Arrays.asList(ia);
//        System.out.println("Before shuffling: " + list1);
//        Collections.shuffle(list1, rand);
//        System.out.println("After shuffling: " + list1);
//        System.out.println("array: " + Arrays.toString(ia));



        String acctIds="1,2,3,4,5,";
        acctIds=acctIds.substring(0,acctIds.length() - 1);
        System.out.println("acctIds:" + acctIds);
        BigDecimal gameWin = BigDecimalUtils.SYSTEM_ZERO;
        BigDecimal gameLost = BigDecimalUtils.valueOf(-1000);
        BigDecimal t1 = BigDecimalUtils.add(gameWin, gameLost);
        System.out.println("t31:" + t1);
        if (BigDecimalUtils.greater(t1, BigDecimalUtils.SYSTEM_ZERO)) {
            t1 = BigDecimalUtils.negate(t1);
        }


        LocalDate now = LocalDate.now();
        int dayof = now.getDayOfWeek().getValue();
        String period = LocalTime.now().toString();

        System.out.println("dayof:" + dayof);

        System.out.println("period:" + period);

        List<String> strings = Arrays.asList("IDR0000012021", "IDR0000012022", "IDR0000002021", "IDR0000003021", "IDR0000004021");
        Collections.sort(strings, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return extractInt(o1) - extractInt(o2);
            }

            int extractInt(String s) {
                String num = s.replaceAll("IDR", "");
                // return 0 if no digits found
                return num.isEmpty() ? 0 : Integer.parseInt(num);
            }
        });
        System.out.println(strings);

//        String taskName = "TP_IDR_SL";
//        String gameCode = taskName.split("_")[0];
//        String currency = taskName.split("_")[1];
//        String gameRoom = taskName.split("_")[2];
//        System.out.println("gameCode:" + gameCode);
//        System.out.println("currency:" + currency);
//        System.out.println("gameRoom:" + gameRoom);
//
//
//        Integer percentage =50;
//        Integer playerCount =5;
//        double num= playerCount*percentage*0.01;
//
//        System.out.println("num:" + num);
//
//
        String currency="";
        if (StringUtils.isEmpty(currency)) {
            System.out.println("currency:" + currency);
        }
        String curr="IDR";
        String  currShort=curr.substring(0,curr.length()-1);
        System.out.println("currShort:" + currShort);
        String gameCode="PK_TP";

        gameCode= gameCode.substring(gameCode.indexOf("_")+1,gameCode.length());
        System.out.println("gameCode:" + gameCode);

        double data = 1 * 30 * 0.01;;
        //利用BigDecimal来实现四舍五入.保留一位0数
        double num = new BigDecimal(data).setScale(0, BigDecimal.ROUND_HALF_UP).doubleValue();
        //1代表保留1位小数,保留两位小数就是2,依此累推
        //BigDecimal.ROUND_HALF_UP 代表使用四舍五入的方式
        System.out.println("result:" +num);//输出3.0
        List<String> stringList = new ArrayList<>();
        stringList.add("a");
        stringList.add("b");
        stringList.add("d");
        stringList.add("d");
        if(num>1){
            num=num-1;
        }

        List<String> result1 = stringList.subList(0, (int) (num));
        for (String s : result1) {
            System.out.println("result String:" +s);//输出3.0
        }
        Integer t2 = 4;
        Integer t3 = 4;

        System.out.println("t1:" + t2.equals(t3));



        Boad2 boad2 = new Boad2();

        System.out.println(boad2.autoShowCard());
        System.out.println(boad2.sendcard());
        System.out.println("t1:" + t1);
//        Boad2 boad23 = null;
//        if (boad23 == null) {
//            boad23 = new Boad2();
//            boad23.setName("sdf111");
//            System.out.println(boad23.getName());
//            System.out.println(boad23.getPayoutCapital());
//        }
//        boad23.setName("sdf");
//        System.out.println(boad23.getName());

//        Long lasTime = 1631860432422L;
//        Long time = System.currentTimeMillis();
//        //模拟花钱看牌下注投注时间（不投注操作）
//        int remaining = (int) ((lasTime - time) / (1000));
//        if (remaining <= 0) {
//            remaining = 12;
//        }
//        int foldToShowSec = RandomUtil.I.genRanDom(1, remaining);
//
//        System.out.println("remaining"+remaining+";foldToShowSec:"+foldToShowSec);
//        System.out.println(RandomUtil.I.genRanDom(1, 0));
    }

}
